import 'package:flutter/material.dart';
import 'package:flutter_basic_learning/utils/CommonWidget.dart';
import 'package:flutter_basic_learning/views/BottomNavigationBar/HomePage.dart';
import 'package:get/get.dart';

class GetRouterPage extends StatefulWidget {
  const GetRouterPage({super.key});

  @override
  State<GetRouterPage> createState() => _GetRouterPageState();
}

Widget getToPage() {
  return ElevatedButton(
    onPressed: () {
      Get.to(const HomePage());
    },
    child: commonTitle('Get.to跳转页面'),
  );
}

Widget getToNamedPage() {
  return ElevatedButton(
    onPressed: () {
      Get.toNamed('/hot', arguments: {'title': 'RouterOnePage'});
      // Get.back();
      // Get.off('/login');
      // Get.off(const LoginPage());
    },
    child: commonTitle('Get.toNamed跳转页面'),
  );
}

Widget back() {
  return ElevatedButton(
      child: commonTitle('返回上一级页面'),
      onPressed: () {
        Get.back();
      });
}

class _GetRouterPageState extends State<GetRouterPage> {
  @override
  Widget build(BuildContext context) {
    return commonScaffold('Get路由学习页面', [
      getToPage(),
      getToNamedPage(),
      back(),
    ]);
  }
}
